__author__ = 'st316'
'''
Given an integer, convert it to a roman numeral.

Input is guaranteed to be within the range from 1 to 3999.
'''


class Solution:
    # @return a string
    def intToRoman(self, num):
        # mapper = {'I': 1, 'V': 5, 'X': 10, 'L': 50, 'C': 100, 'D': 500, 'M': 1000}
        n = 3
        numOfm, remainder = num / 1000, num % 1000
        numOfd, remainder = remainder / 500, remainder % 500
        numOfc, remainder = remainder / 100, remainder % 100
        numOfl, remainder = remainder / 50, remainder % 50
        numOfx, remainder = remainder / 10, remainder % 10
        numOfv, numOfi = remainder / 5, remainder % 5
        s = 'M' * numOfm + 'D' * numOfd
        if numOfc > n:
            s += 'CD'
        else:
            s += 'C' * numOfc
        s += 'L' * numOfl
        if numOfx > n:
            s += 'XL'
        else:
            s += 'X' * numOfx
        s += 'V' * numOfv
        if numOfi > n:
            s += 'IV'
        else:
            s += 'I' * numOfi
        return s.replace('VIV', 'IX').replace('LXL', 'XC').replace('DCD', 'CM')

    # @return a string
    def intToRomanX(self, num):
        n = 3
        numOfm, remainder = num / 1000, num % 1000
        numOfd, remainder = remainder / 500, remainder % 500
        numOfc, remainder = remainder / 100, remainder % 100
        numOfl, remainder = remainder / 50, remainder % 50
        numOfx, remainder = remainder / 10, remainder % 10
        numOfv, numOfi = remainder / 5, remainder % 5
        s = 'M' * numOfm + 'D' * numOfd
        if numOfc > n:
            s = (s[:-1] + 'CM') if s and s[-1] == 'D' else s + 'CD'
        else:
            s += 'C' * numOfc
        s += 'L' * numOfl
        if numOfx > n:
            s = (s[:-1] + 'XC') if s and s[-1] == 'L' else s + 'XL'
        else:
            s += 'X' * numOfx
        s += 'V' * numOfv
        if numOfi > n:
            s = (s[:-1] + 'IX') if s and s[-1] == 'V' else s + 'IV'
        else:
            s += 'I' * numOfi
        return s


if __name__ == '__main__':
    s = Solution()
    # for x in xrange(21):
    #     print s.intToRoman(x),
    # print
    for x in xrange(14, 15):
        print s.intToRomanX(x),